package com.xiaouyudeguang.common.handler;

import com.xiaouyudeguang.common.utils.JsonObject;
import com.xiaouyudeguang.common.utils.RequestUtils;
import org.springframework.web.HttpRequestHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public interface DefaultHttpRequestHandler extends HttpRequestHandler {

    default void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().print(JsonObject.readTree(RequestUtils.getParameters(request)));
    }
}
